package org.example.attendancesystem.controller;

import org.example.attendancesystem.domain.*;
import org.example.attendancesystem.service.SessionParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/session")
public class SessionController {
    @Autowired
    private SessionParamsService sessionParamsService;
    @PostMapping("/addMap")
    public Result<String> addSessionParams(@RequestBody Map map) {
        System.out.println(map);
        SessionParams sessionParams = new SessionParams();
        sessionParams.setSessionType(map.getSessionType());
        sessionParams.setLatitude(map.getLatitude());
        sessionParams.setLongitude(map.getLongitude());
        sessionParams.setRadius(map.getRadius());
        System.out.println(sessionParams);
<<<<<<< HEAD
=======
        // 新增签到码处理
>>>>>>> e774734 (签到码签到功能)
        boolean isSuccess = sessionParamsService.save(sessionParams);
        if (isSuccess) {
            return Result.success("添加成功");
        } else {
            return Result.fail("添加失败");
        }

    }
    @PostMapping("/addCode")
    public Result<String> addCode(@RequestBody Code code){
        System.out.println(code);
        SessionParams sessionParams= new SessionParams();
        sessionParams.setSessionType(code.getSessionType());
        sessionParams.setPatternCode(code.getPatternCode());
        boolean isSuccess = sessionParamsService.save(sessionParams);
        if (isSuccess) {
            return Result.success("添加成功");
        } else {
            return Result.fail("添加失败");
        }
    }
    @PostMapping("/addGesture")
    public Result<String> addCode(@RequestBody Gesture gesture){
        System.out.println(gesture);
        SessionParams sessionParams= new SessionParams();
        sessionParams.setSessionType(gesture.getSessionType());
        sessionParams.setPatternCode(gesture.getPatternCode());
        boolean isSuccess = sessionParamsService.save(sessionParams);
        if (isSuccess) {
            return Result.success("添加成功");
        } else {
            return Result.fail("添加失败");
        }
    }

    @GetMapping
    public Result<String > helloworld() {
        return Result.success("hellow world");
    }
<<<<<<< HEAD
=======


>>>>>>> e774734 (签到码签到功能)
}
